import '@ant-design/compatible/assets/index.css';
import React, { useState, useEffect } from 'react';
import { PageHeaderWrapper } from "@ant-design/pro-layout";
import {message, Spin} from 'antd';
import DataForm from './components/VideoForm';
import {queryRule} from './service';

export default (props: any)=>{
  // common数据
  const [common, setCommon] = useState({});
  // 表单数据
  const [dataFormValues, setDataFormValues] = useState({post_append: {}});
  const [imageValues, setImageValues] = useState<any>({});
  // 初始化loading
  const [initLoading, setInitLoading] = useState(true);

  const { location } = props;

  const isUpdate: boolean = true;
 console.log(isUpdate)
 useEffect(() => {
   //请求当前一组配置参数，tag=storageVideos
  queryRule({tag:'storageVideos'}).then(res=>{
    if(res.code == 0){
      setCommon(res.data.common);
      if(res.data.list && res.data.list.length>0){
        setDataFormValues(res.data.list[0]?.item_value_decode);
      }
    }else{
      message.error(res.message);
    }
      setInitLoading(false);
    });
}, []);

  return <Spin spinning={initLoading}>
      {initLoading && <div style={{height: '500px',backgroundColor: '#fff'}} />}
      {!initLoading && <DataForm 
                          isUpdate={isUpdate}
                          dataFormValues={dataFormValues}
                          imageValues={imageValues}
                          common={common}/>}
    </Spin>
};
